#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
int isPrime(int x)
{
	int flag = 1;
	if (x == 2) flag = 1;
	else
	{
		for (int j = 2; j <= (int)sqrt(x); j++)
		{
			if (x % j == 0) flag = 0;
		}
	}
	return flag;
}
int main()
{
	int m, n, cnt = 0;
	scanf("%d%d", &m, &n);
	for (int i = m; i <= n - 2; i++)
	{
		if (isPrime(i) == 1 && isPrime(i + 2) == 1)
		{
			cnt++;
		}
	}
	printf("%d", cnt);
	return 0;
}